//
//  PushOutBottomView.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/6/29.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "PushOutBottomView.h"

@interface PushOutBottomView ()

@property (nonatomic, weak)UIButton * QQButton;

@property (nonatomic, weak)UIButton * weixinButton;

@property (nonatomic, weak)UIButton * friendsButton;

@property (nonatomic, weak)UIButton * buttomButton;

@property (nonatomic, weak)UILabel * QQLabel;

@property (nonatomic, weak)UILabel * weixinLabel;

@property (nonatomic, weak)UILabel * friendsLabel;

@end

@implementation PushOutBottomView



- (instancetype)initWithFrame:(CGRect)frame{
    
    if ([super initWithFrame:frame]) {
        
        [self setupUI];
    }
    
    return self;
}


- (void)setupUI{
    
    self.backgroundColor = ColorWithRGB(0xf4f4f4);
    
    UIButton * QQbutton = [UIButton new];
    
    [QQbutton setImage:[UIImage imageNamed:@"qq"] forState:UIControlStateNormal];
    [QQbutton addTarget:self action:@selector(didShareButton:) forControlEvents:UIControlEventTouchUpInside];
    
    self.QQButton = QQbutton;
    
    [self addSubview:self.QQButton];
    
    UIButton * weixinButton = [UIButton new];
    
    [weixinButton setImage:[UIImage imageNamed:@"微信好友"] forState:UIControlStateNormal];
    [weixinButton addTarget:self action:@selector(didShareButton:) forControlEvents:UIControlEventTouchUpInside];
    
    self.weixinButton = weixinButton;
    
    [self addSubview:self.weixinButton];
    
    UIButton * friendsButton = [UIButton new];
    
    [friendsButton setImage:[UIImage imageNamed:@"朋友圈"] forState:UIControlStateNormal];
    [friendsButton addTarget:self action:@selector(didShareButton:) forControlEvents:UIControlEventTouchUpInside];
    
    self.friendsButton = friendsButton;
    
    [self addSubview:self.friendsButton];
    
    
    UILabel * QQLabel = [UILabel new];
    
    QQLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    QQLabel.text = @"QQ好友";
    QQLabel.textColor = ColorWithRGB(0x151515);
    
    self.QQLabel = QQLabel;
    
    [self addSubview:self.QQLabel];
    
    UILabel * weixinLabel = [UILabel new];
    
    weixinLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    weixinLabel.text = @"微信好友";
    weixinLabel.textColor = ColorWithRGB(0x151515);
    
    self.weixinLabel = weixinLabel;
    
    [self addSubview:self.weixinLabel];
    
    UILabel * friendsLabel = [UILabel new];
    
    friendsLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    friendsLabel.text = @"朋友圈";
    friendsLabel.textColor = ColorWithRGB(0x151515);
    
    self.friendsLabel = friendsLabel;
    
    [self addSubview:self.friendsLabel];
    
    UIButton * bottomButton = [UIButton new];
    
    [bottomButton setBackgroundColor:ColorWithRGB(0xffffff)];
    [bottomButton setTitle:@"取消" forState:UIControlStateNormal];
    bottomButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    [bottomButton setTitleColor:ColorWithRGB(0x151515) forState:UIControlStateNormal];
    [bottomButton addTarget:self action:@selector(didCancelButton) forControlEvents:UIControlEventTouchUpInside];
    
    self.buttomButton = bottomButton;
    
    [self addSubview:self.buttomButton];
}


- (void)layoutSubviews{

    [self.weixinButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self).offset(22 * SCREENH6);
        make.centerX.mas_equalTo(self);
        make.width.height.mas_equalTo(53 * SCREENH6);
    }];

    [self.QQButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.weixinButton);
        make.trailing.mas_equalTo(self.weixinButton.mas_leading).offset(- 75 * SCREENH6);
        make.width.height.mas_equalTo(53 * SCREENH6);
    }];

    [self.friendsButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.weixinButton);
        make.leading.mas_equalTo(self.weixinButton.mas_trailing).offset( 75 * SCREENH6);
        make.width.height.mas_equalTo(53 * SCREENH6);
    }];

    [self.QQLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.QQButton.mas_bottom).offset(15 * SCREENH6);
        make.centerX.mas_equalTo(self.QQButton);
    }];

    [self.weixinLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.weixinButton.mas_bottom).offset(15 * SCREENH6);
        make.centerX.mas_equalTo(self.weixinButton);
    }];
    
    [self.friendsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.friendsButton.mas_bottom).offset(15 * SCREENH6);
        make.centerX.mas_equalTo(self.friendsButton);
    }];

    [self.buttomButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.mas_equalTo(self);
        make.height.mas_equalTo(45 * SCREENH6);
        make.top.mas_equalTo(self.weixinLabel.mas_bottom).offset(15 * SCREENH6);
    }];
}



- (void)didShareButton:(UIButton *)button{
    
    if (button == self.QQButton) {
        
        NSLog(@"点击QQ按钮");
        
    }else if (button == self.weixinButton){
        
        NSLog(@"点击微信按钮");
    }else{
        
        NSLog(@"点击朋友圈按钮");
    }
    
}


- (void)didCancelButton{
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"didCancleButton" object:nil];
}



@end
